/**
 * 
 */
package com.taobao.client.sdk;

import java.util.Map;

import com.google.gwt.user.client.Window;
import com.taobao.client.Data;

/**
 * The input parameters of applying a trade refund
 * 
 * @author hujingfei.pt
 *
 */
public class RefundApplyRequest extends CommonRequest {
	
	// The id of the trade.
	private String biz_order_id;
	// The callback url.
	private String callback_url;
	// The url of the top page.
	private String top_url;
	// The url of the bottom page.
	private String bottom_url;
	// The remark of the auction.
	private String auction_remark;
	// The remark of the order.
	private String order_remark;
	// The height of the top of the page.
	private String top_height;
	// The height of the bottom of the page.
	private String bottom_height;
	// The encoding
	private String encoding;
	
	/**
	 * Default constructor
	 */
	public RefundApplyRequest(){}
	
	/**
	 * Constructor
	 */
	public RefundApplyRequest(String biz_order_id, String callback_url, String top_url, String bottom_url, String auction_remark
			, String order_remark, String top_height, String bottom_height, String encoding) {
		this.biz_order_id = biz_order_id;
		this.callback_url = callback_url;
		this.top_url = top_url;
		this.bottom_url = bottom_url;
		this.auction_remark = auction_remark;
		this.order_remark = order_remark;
		this.top_height = top_height;
		this.bottom_height = bottom_height;
		this.encoding = encoding;
	}

	
	/**
	 * @param pairs the hashmap whose contents are set
	 */
	public void setMapContent(Map<String, String> pairs) {
		pairs.put("method", Data.API_REFUND_APPLY);
		pairs.put("biz_order_id", biz_order_id);
		pairs.put("callback_url", callback_url);
		pairs.put("top_url", top_url);
		pairs.put("bottom_url", bottom_url);
		pairs.put("auction_remark", auction_remark);
		pairs.put("order_remark", order_remark);
		pairs.put("top_height", top_height);
		pairs.put("bottom_height", bottom_height);
		pairs.put("encoding", encoding);
	}
	
	/**
	 * Initialize unchangeable parameters
	 */
	public void initialize(){
		setCallback_url(Window.Location.getHref());
		// Get the url's protocol, host and port name
		String top_url = Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/" + Data.TOP_URL;
		setTop_url(top_url);
					
		String bottom_url = Window.Location.getProtocol() + "//" +  Window.Location.getHost() + "/" + Data.BOTTOM_URL;
		setBottom_url(bottom_url);
		
		setTop_height(DEFAULT_HEIGHT);
		setBottom_height(DEFAULT_HEIGHT);
		
		setEncoding("gb2312");
	}
	
	/**
	 * @return the biz_order_id
	 */
	public String getBiz_order_id() {
		return biz_order_id;
	}

	/**
	 * @param bizOrderId the biz_order_id to set
	 */
	public void setBiz_order_id(String bizOrderId) {
		biz_order_id = bizOrderId;
	}

	/**
	 * @return the callback_url
	 */
	public String getCallback_url() {
		return callback_url;
	}

	/**
	 * @param callbackUrl the callback_url to set
	 */
	public void setCallback_url(String callbackUrl) {
		callback_url = callbackUrl;
	}

	/**
	 * @return the top_url
	 */
	public String getTop_url() {
		return top_url;
	}

	/**
	 * @param topUrl the top_url to set
	 */
	public void setTop_url(String topUrl) {
		top_url = topUrl;
	}

	/**
	 * @return the bottom_url
	 */
	public String getBottom_url() {
		return bottom_url;
	}

	/**
	 * @param bottomUrl the bottom_url to set
	 */
	public void setBottom_url(String bottomUrl) {
		bottom_url = bottomUrl;
	}

	/**
	 * @return the auction_remark
	 */
	public String getAuction_remark() {
		return auction_remark;
	}

	/**
	 * @param auctionRemark the auction_remark to set
	 */
	public void setAuction_remark(String auctionRemark) {
		auction_remark = auctionRemark;
	}

	/**
	 * @return the order_remark
	 */
	public String getOrder_remark() {
		return order_remark;
	}

	/**
	 * @param orderRemark the order_remark to set
	 */
	public void setOrder_remark(String orderRemark) {
		order_remark = orderRemark;
	}

	/**
	 * @return the top_height
	 */
	public String getTop_height() {
		return top_height;
	}

	/**
	 * @param topHeight the top_height to set
	 */
	public void setTop_height(String topHeight) {
		top_height = topHeight;
	}

	/**
	 * @return the bottom_height
	 */
	public String getBottom_height() {
		return bottom_height;
	}

	/**
	 * @param bottomHeight the bottom_height to set
	 */
	public void setBottom_height(String bottomHeight) {
		bottom_height = bottomHeight;
	}

	/**
	 * @return the encoding
	 */
	public String getEncoding() {
		return encoding;
	}

	/**
	 * @param encoding the encoding to set
	 */
	public void setEncoding(String encoding) {
		this.encoding = encoding;
	}
	
}
